#!/bin/bash
# /etc/init.d/interaction

# change to executable
# sudo chmod +x /etc/init.d/interaction

# reboot
# start
# sudo service interaction start

# start defaults
# sudo update-rc.d interaction defaults

# stop
# sudo service interaction stop

### BEGIN INIT INFO
# Provides: cc
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: interaction initscript
# Description: This service is used to autostart interaction warning system
### END INIT INFO

case "$1" in
  start)
    echo "Starting interaction"
    /home/pi/dev/app.py &
  ;;
  stop)
    echo "Stopping interaction"
    # killall
    kill $(ps aux | grep -m 1 'python3 /home/pi/dev/app.py' | awk '{ print $2 }')
  ;;
  *)
    echo "Usage: service interaction start|stop"
    exit 1
  ;;
esac
exit 0
